csd: Fix invisible border/shadow confusion
authorMatthias Clasen <mclasen@redhat.com>
Wed, 12 Mar 2014 04:15:02 +0000 (00:15 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 12 Mar 2014 04:18:04 +0000 (00:18 -0400)
We did not set an input shape on the window, so the region outside
the invisible border where we draw the outer edges of the shadow
were still part of the window, as far as clicks and cursors were
concerned. Fix this by setting an input shape that makes all clicks
outside of the resize borders go through to the underlying window.

https://bugzilla.gnome.org/show_bug.cgi?id=726125

gtk/gtkwindow.c

index 56955e4120eb53c4d982e0da92ef80993d361044..59d2a037cd088535cb815abc9d8f5e130a3e8850 100644 (file)
@@ -6512,6 +6512,16 @@ max_borders (GtkBorder *one,
   one->left = MAX (one->left, two->left);
 }
 
+static void
+subtract_borders (GtkBorder *one,
+                  GtkBorder *two)
+{
+  one->top -= two->top;
+  one->right -= two->right;
+  one->bottom -= two->bottom;
+  one->left -= two->left;
+}
+
 static void
 add_window_frame_style_class (GtkStyleContext *context)
 {
@@ -6834,6 +6844,19 @@ update_border_windows (GtkWindow *window)
       gdk_window_hide (priv->border_window[GDK_WINDOW_EDGE_WEST]);
       gdk_window_hide (priv->border_window[GDK_WINDOW_EDGE_EAST]);
     }
+
+  /* we also update the input shape, which makes it so that clicks
+   * outside the border windows go through
+   */
+
+  subtract_borders (&window_border, &border);
+  rect.x = window_border.left;
+  rect.y = window_border.top;
+  rect.width = gtk_widget_get_allocated_width (widget) - window_border.left - window_border.right;
+  rect.height = gtk_widget_get_allocated_height (widget) - window_border.top - window_border.bottom;
+  region = cairo_region_create_rectangle (&rect);
+  gtk_widget_input_shape_combine_region (widget, region);
+  cairo_region_destroy (region);
 }
 
 static void